﻿<!DOCTYPE html>
<html>
<head>
    <title>OData Helper for WebMatrix</title>
    <link href="content/Site.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
</head>
<body>
    <div class="container">
        <div class="header">
            <img src="content/images/webx-icon.png" alt="WebMatrix" />
            <h1>
                WebMatrix Helpers</h1>
            <h2>
                OData Helper - Start Here</h2>
        </div>
        <div class="content">
            <h3>
                Introduction</h3>
            <p>
                Microsoft WebMatrix provides an easy way to get started with web development, and
                together with new Razor syntax for ASP.NET Web Pages it includes everything you
                need to get your web site up, running and integrated with many other sites and networks,
                in a short period of time. The WebMatrix helpers are designed to make your life
                easier when creating web sites. They provide you a simple and consistent way of
                performing common web development tasks that otherwise would require a great deal
                of custom coding. With a few lines of code you should be able to secure your web
                site using membership, store information in Windows Azure Storage, integrate your
                site with Facebook, among others things.
            </p>
            <p>
                The OData helper allows you to easily retrieve and update data from any service
                that expose its data using the OData Protocol. It does not require that you configure
                any specific client or create any custom class; by pointing the helper to the correct
                URL, you can have all the data you need ready to be displayed using the Razor syntax.
            </p>
             <h3>
                Getting Started in 60 Seconds</h3>
            <p>
                The helper consists mainly of a <strong>Microsoft.Web.Helpers.OData.dll</strong> library 
                located into the <strong>Bin</strong> folder of your WebMatrix site.
                To use the OData helper follow these steps:</p>
            <ol>
                <li>In any WebMatrix page, add the following highlighted code. This will query the <a href="http://developer.netflix.com/docs/OData_Catalog">NetFlix OData service</a>:
                    <div class="code">                        
                        <span class="highlight">@{<br /></span>
                        <span class="codeIndent1 highlight">var result = 
                        OData.Get(&quot;http://odata.netflix.com/Catalog/Genres(&#39;Horror&#39;)/Titles&quot;,&quot;$orderby=AverageRating 
                        desc&amp;$top=5&quot;);</span><br />
                        <span class="codeIndent1 highlight">var grid = new WebGrid(result);</span><br />                         
                        <span class="highlight">}</span><br />
                        &lt;!DOCTYPE html&gt;<br />
                        &lt;html&gt;<br />
                        <span class="codeIndent1">...<br /></span>
                        <span class="codeIndent1">&lt;body&gt;<br /></span>
                        <span class="codeIndent2 highlight">@grid.GetHtml()</span><br />    
                        <span class="codeIndent2">...<br /></span>                
                        <span class="codeIndent1">&lt;/body&gt;<br /></span>                        
                        &lt;/html&gt;</div>
                </li>
                <li>For more examples of queries check out the helper samples!</li>
            </ol>
            <h3>
                Running the Samples</h3>
            <p>
                The helper package includes a set of WebMatrix pages where you can see the helper in action. To run them follow these steps:</p>
            <ol>               
                <li>In Microsoft WebMatrix, under the Files workspace, right-click the <strong>ODataHelper\SampleApp</strong> folder and select
                    '<strong>Launch in browser</strong>'. This will open the sample web site with WebMatrix.</li>                
                <li>Play with the samples!</li>
            </ol>           
            <h3>
                More Info</h3>
            <p>
                To explore the helper's implementation you can download its source code from the <a href="http://odatahelper.codeplex.com/">OData Helper CodePlex project</a>; it includes unit tests for the helpers
                methods.            
            <p>
                Learn more on WebMatrix, ASP.NET Web Pages and the Razor Syntax with <a href="http://www.microsoft.com/web/webmatrix/learn/">the WebMatrix tutorials.</a></p>
        </div>
        <ul class="footer">
            <li>We're always looking for <a href="mailto:webapp@microsoft.com">
                bugs, feedback and suggestions!</a></li>
            <li>&copy; 2010-2011 Microsoft Corporation. Powered by IIS Express.</li>
        </ul>
    </div>
</body>
</html>
